const baseConfig = require('./webpack.common');
const { merge } = require('webpack-merge');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = merge(baseConfig, {
  mode: 'production',
  devtool: 'cheap-module-eval-source-map',
  output: {
    filename: 'bundle-[contenthash:8].js',
  },
  optimization: {
    sideEffects: true,
    concatenateModules: true,
    minimize: true,
  },
  plugins: [
    new webpack.DefinePlugin({
      BASE_URL: '""',
    }),
    new CleanWebpackPlugin(),
    new CopyWebpackPlugin({
      patterns: ['public'],
    }),
  ],
});
